module.exports = function (req, res, next) {
  res.success = function (data, message = "ok") {
    res.json({
      code: 200,
      data: data,
      message: message,
      success: true
    })
  }

  res.error = function (message, statusCode = 400) {
    res.status(statusCode).json({
      code: statusCode,
      message: message,
      path: req.path,
      timestamp: new Date().getTime(),
      success: false
    })
  }

  next()
} 